package com.ebao.service.mail;

import java.util.Map;

import javax.mail.MessagingException;

import org.springframework.core.io.ClassPathResource;
import org.springframework.mail.MailException;
import org.springframework.mail.SimpleMailMessage;

public interface IMailService {

	/**
	 * Send a simple message with pre-populated values.
	 * 
	 * @param msg the message to send
	 * @throws org.springframework.mail.MailException when SMTP server is down
	 */
	public abstract void sendMessage(SimpleMailMessage msg) throws MailException;

	/**
	 * Send a simple message based on a Velocity template.
	 * 
	 * @param msg the message to populate
	 * @param templateName the Velocity template to use (relative to classpath)
	 * @param model a map containing key/value pairs
	 */
	public abstract void sendMessage(SimpleMailMessage msg, String templateName, Map<String, Object> model);

	/**
	 * Convenience method for sending messages with attachments.
	 * 
	 * @param recipients array of e-mail addresses
	 * @param sender e-mail address of sender
	 * @param subject  subject of e-mail
	 * @param bodyText text in e-mail
	 * @param resource attachment from classpath
	 * @param attachmentName  name for attachment
	 * @throws MessagingException thrown when can't communicate with SMTP server
	 * @throws javax.mail.MessagingException
	 */
	public abstract void sendMessage(String[] recipients, String sender,
			String subject, String bodyText, ClassPathResource resource,
			String attachmentName) throws MessagingException;

	public void sendMessage(String[] recipients, String sender, String subject,
			String templateName, Map<String, Object> model,
			ClassPathResource resource, String attachmentName)
			throws MessagingException;
	
}